#include "boom.h"
#include <QPainter>
Boom::Boom(Game *game,QPoint p) :
    pos(p),game(game)
{
        movie = new QMovie(":/img/boom.gif");
        //ui->m_pgifLabel->setMovie(movie);
        movie->start();
        // 更新间隔
        startTimer(30);
}
void Boom::draw(QPainter *p)
{
    if(movie->currentFrameNumber()==7)
        end();
    p->save();
    p->translate(pos);
    QPixmap sprite(movie->currentPixmap());
    sprite=sprite.scaled(65,60);
    QPoint drawPos(-sprite.width()/2,-sprite.height()/2);
    p->drawPixmap(drawPos,sprite);
    p->resetTransform();
    p->restore();
}

void Boom::end()
{
    game->remove_boom(this);
}
Boom::~Boom()
{

}
